home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / ms-0.07 / lib / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-27  |  383 b   |  23 lines

  1. /* strdup.c -- strdup() replacement for machines that lack it */
  2.  
  3. #ifdef NO_STRDUP
  4.  
  5. #include <string.h>
  6.  
  7. /*
  8.   It is impossible to declare malloc() in a portable way.
  9.   Be prepared to change this declaration.
  10. */
  11. void *malloc();
  12.  
  13. char *
  14. strdup(str) 
  15.      char *str;
  16. { unsigned int length = strlen(str);
  17.   char *r = (char *) malloc(length + 1);
  18.   strcpy(r, str);
  19.   return(r);
  20. }
  21.  
  22. #endif
  23.